package com.bestom.bluetoothlock.views;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.bestom.bluetoothlock.R;


public class DeviceSettingDialog extends Dialog {
    private View customView;
    private Context mContext;
    public OnChangeClickListener mOnChangeClickListener;
    public OnChangePasswordClickListener mOnChangePasswordClickListener;
    public OnResetClickListener mOnResetClickListener;
    public OnUnbindClickListener mOnUnbindClickListener;
    private TextView tv_cancel;
    private TextView tv_change_name;
    private TextView tv_change_password;
    private TextView tv_reset;
    private TextView tv_unbind;

    public interface OnChangeClickListener {
        void onChangeClick(View view);
    }

    public interface OnChangePasswordClickListener {
        void onChangeClick(View view);
    }

    public interface OnResetClickListener {
        void onResetClick(View view);
    }

    public interface OnUnbindClickListener {
        void onUnbindClick(View view);
    }

    public DeviceSettingDialog(Context context) {
        super(context, R.style.FullScreenDialog);
        this.mContext = context;
        this.customView = LayoutInflater.from(context).inflate(R.layout.dialog_device_setting, (ViewGroup) null);
    }

    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setContentView(this.customView);
        initView();
    }

    private void initView() {
        this.tv_change_name = (TextView) this.customView.findViewById(R.id.tv_change_name);
        this.tv_change_password = (TextView) this.customView.findViewById(R.id.tv_change_password);
        this.tv_unbind = (TextView) this.customView.findViewById(R.id.tv_unbind);
        this.tv_cancel = (TextView) this.customView.findViewById(R.id.tv_cancel);
        this.tv_reset = (TextView) this.customView.findViewById(R.id.tv_reset);
        this.tv_cancel.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                DeviceSettingDialog.this.dismiss();
            }
        });
        this.tv_change_name.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                DeviceSettingDialog.this.mOnChangeClickListener.onChangeClick(view);
            }
        });
        this.tv_change_password.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                DeviceSettingDialog.this.mOnChangePasswordClickListener.onChangeClick(view);
            }
        });
        this.tv_unbind.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                DeviceSettingDialog.this.mOnUnbindClickListener.onUnbindClick(view);
                DeviceSettingDialog.this.dismiss();
            }
        });
        this.tv_reset.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                DeviceSettingDialog.this.mOnResetClickListener.onResetClick(view);
                DeviceSettingDialog.this.dismiss();
            }
        });
    }

    public void setOnChangeClickListener(OnChangeClickListener onChangeClickListener) {
        this.mOnChangeClickListener = onChangeClickListener;
    }

    public void setOnChangePasswordClickListener(OnChangePasswordClickListener onChangePasswordClickListener) {
        this.mOnChangePasswordClickListener = onChangePasswordClickListener;
    }

    public void setOnUnbindClickListener(OnUnbindClickListener onUnbindClickListener) {
        this.mOnUnbindClickListener = onUnbindClickListener;
    }

    public void setOnResetClickListener(OnResetClickListener onResetClickListener) {
        this.mOnResetClickListener = onResetClickListener;
    }
}
